import { Component } from 'react'
import  Taro  from '@tarojs/taro'
import { View, Swiper, SwiperItem, Image } from '@tarojs/components'
import './index.scss'

export default class Index extends Component {
  state = {
    bannerList: []
  }
  componentWillMount () { }

  componentDidMount () {
    Taro.request({
      url: 'http://121.89.205.189/api/banner/list',
      success: (res) => {
        console.log(res)
        this.setState({
          bannerList: res.data.data
        })
      }
    })
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  render () {
    return (
      <View className='index'>
        <Swiper>
          {
            this.state.bannerList.map(item => {
              return(
                <SwiperItem key = { item.bannerid }>
                  <Image src={ item.img }></Image>
                </SwiperItem>
              )
            })
          }
        </Swiper>
      </View>
    )
  }
}
